package com.djl.transaction;

import com.djl.configuration.ClassPathMapperScanner;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

import javax.sql.DataSource;
public class TransactionManager {

    public static PlatformTransactionManager acquireTransactionManager() {
        //将数据源交给事务管理器
        DataSource dataSource = ClassPathMapperScanner.DATASOURCE;

        PlatformTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);

        return new TxStackHolderPlatformTransactionManager(transactionManager);
    }

}
